package com.wa.base.dataPermission;


import java.util.HashMap;
import java.util.Map;

/**
 * 数据权限--数据类型
 *
 * @author Homan Liang
 * @date 2019/11/1
 */
public enum DataPermissionDataTypeEnum {
    /**
     * big int
     */
    BIGINT("bigint", "integer"),
    BIT("bit", "integer"),
    INT("int", "integer"),
    SMALLINT("smallint", "integer"),
    TINYINT("tinyint", "integer"),
    DECIMAL("decimal", "decimal"),
    DOUBLE("double", "decimal"),
    FLOAT("float", "decimal"),
    BLOB("blob", "string"),
    CHAR("char", "string"),
    ENUM("enum", "string"),
    LONG_BLOB("longblob", "string"),
    LONG_TEXT("longtext", "string"),
    MEDIUM_BLOB("mediumblob", "string"),
    MEDIUM_TEXT("mediumtext", "string"),
    VARCHAR("varchar", "string"),
    TEXT("text", "string"),
    SET("set", "string"),
    DATETIME("datetime", "datetime"),
    TIME("time", "datetime"),
    TIMESTAMP("timestamp", "datetime"),
    DATE("date", "datetime"),
    ;

    /**
     * 数据类型
     */
    private String dataType;
    /**
     * 分类
     */
    private String category;

    private static final Map<String, DataPermissionDataTypeEnum> lookup = new HashMap<>();

    static {
        for (DataPermissionDataTypeEnum ase : DataPermissionDataTypeEnum.values()) {
            lookup.put(ase.getDataType(), ase);
        }
    }

    DataPermissionDataTypeEnum(String dataType, String category) {
        this.dataType = dataType;
        this.category = category;
    }

    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public static DataPermissionDataTypeEnum get(String dataType) {
        return lookup.get(dataType);
    }
}
